﻿<?php
/**
 * @version		$Id: index.php 17268 2010-05-25 20:32:21Z a.radtke $
 * @package		Joomla.Site
 * @subpackage	tl_JM-SCHOOL
 * @copyright	Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access.
defined('_JEXEC') or die;

// check modules
$showRightColumn	= ($this->countModules('position-3') or $this->countModules('position-6') or $this->countModules('position-8'));
$showbottom			= ($this->countModules('position-9') or $this->countModules('position-10') or $this->countModules('position-11'));
$showleft			= ($this->countModules('position-4') or $this->countModules('position-7') or $this->countModules('position-5'));

if ($showRightColumn==0 and $showleft==0) {
	$showno = 0;
}

JHTML::_('behavior.mootools');

// get params
$color			= $this->params->get('templatecolor');
$logo			= $this->params->get('logo');
$navposition	= $this->params->get('navposition');
$app			= JFactory::getApplication();
$templateparams	= $app->getTemplate(true)->params;
$db =& JFactory::getDBO();
?>
<?php if(!$templateparams->get('html5', 0)): ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php else: ?>
	<?php echo '<!DOCTYPE html>'; ?>
<?php endif; ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >
	<head><title>09信工4</title>
		<jdoc:include type="head" />
		<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css" type="text/css" />
		<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/jm-school/css/position.css" type="text/css" media="screen,projection" />
		<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/jm-school/css/layout.css" type="text/css" media="screen,projection" />
		<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/jm-school/css/print.css" type="text/css" media="Print" />
		<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/jm-school/css/jm-school.css" type="text/css" />
<?php
	$files = JHtml::_('stylesheet','templates/jm-school/css/general.css',null,false,true);
	if ($files):
		if (!is_array($files)):
			$files = array($files);
		endif;
		foreach($files as $file):
?>
		<link rel="stylesheet" href="<?php echo $file;?>" type="text/css" />
<?php
	 	endforeach;
	endif;
?>
		<?php if ($this->direction == 'rtl') : ?>
		<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/jm-school/css/template_rtl.css" type="text/css" />
		<?php endif; ?>
		<!--[if lte IE 6]>
			<link href="<?php echo $this->baseurl ?>/templates/jm-school/css/ieonly.css" rel="stylesheet" type="text/css" />
		<![endif]-->
		<!--[if IE 7]>
			<link href="<?php echo $this->baseurl ?>/templates/jm-school/css/ie7only.css" rel="stylesheet" type="text/css" />
		<![endif]-->
<?php if($templateparams->get('html5', 0)) { ?>
		<!--[if lt IE 9]>
			<script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/jm-school/javascript/html5.js"></script>
		<![endif]-->
<?php } ?>
		<script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/jm-school/javascript/md_stylechanger.js"></script>
		<script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/jm-school/javascript/hide.js"></script>
		<script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/jm-school/javascript/jquery.js"></script>
		<script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/jm-school/javascript/js.js"></script>

		<script type="text/javascript">
			var big ='<?php echo (int)$this->params->get('wrapperLarge');?>%';
			var small='<?php echo (int)$this->params->get('wrapperSmall'); ?>%';
			var altopen='<?php echo JText::_('TPL_JM-SCHOOL_ALTOPEN',true); ?>';
			var altclose='<?php echo JText::_('TPL_JM-SCHOOL_ALTCLOSE',true); ?>';
			var bildauf='<?php echo $this->baseurl ?>/templates/jm-school/images/plus.png';
			var bildzu='<?php echo $this->baseurl ?>/templates/jm-school/images/minus.png';
			var rightopen='<?php echo JText::_('TPL_JM-SCHOOL_TEXTRIGHTOPEN',true); ?>';
			var rightclose='<?php echo JText::_('TPL_JM-SCHOOL_TEXTRIGHTCLOSE'); ?>';
			var fontSizeTitle='<?php echo JText::_('Font Size :'); ?>';
            var bigger='<?php echo JText::_('Bigger'); ?>';
            var reset='<?php echo JText::_('Reset'); ?>';
            var smaller='<?php echo JText::_('Smaller'); ?>';
            var biggerTitle='<?php echo JText::_('TPL_JM-SCHOOL_INCREASE_SIZE'); ?>';
            var resetTitle='<?php echo JText::_('TPL_JM-SCHOOL_REVERT_STYLES_TO_DEFAULT'); ?>';
            var smallerTitle='<?php echo JText::_('TPL_JM-SCHOOL_DECREASE_SIZE'); ?>';
		</script>

	</head>

	<body>
		
			<div id = "menu">
				<div id = "xingong4">
					<h1><a href = "<?php echo $this->baseurl;?>"/index.php">电子与信息学院 09信息工程4班</a></h1>
				</div>
				<div id = "menuls">
					<jdoc:include type="modules" name="position-1" />
				</div>
			</div>
			
			
			

		<div id = "wrapframe">
			<div id="<?php echo $showRightColumn ? 'wrapper' : 'wrapper2'; ?>" <?php if (isset($showno)){echo 'class="shownocolumns"';}?>>

					
					
					
				
				
					
					
				<?php
					//if it is the frontpage
					$menu=&JSite::getMenu();//print_r($menu->getActive());
					if ($this->countModules('position-01')==0&&($menu->getActive()==$menu->getDefault())):
						$query = 'select con.created,con.introtext
							from
							#__content as con
							where
							con.catid =(select id from `#__categories` where alias="headerpic")
							and con.state=1
							order by con.publish_up desc
							limit 0,3';
						$db->setQuery($query);
						$headpics = $db->loadObjectList();
							
						$pattern = "/<img.*?src=\"(.*?)\".*?>/i";
						$introtext_limit = 45;
						echo "<div id = 'stagebg'></div>";
						echo "<div id = 'stage'>";
						echo "<div id = 'stagepic'><ul>";
						for($i=0;$i<3&&isset($headpics[$i]);$i++){
							// Get the image url
							if (preg_match($pattern, $headpics[$i]->introtext, $matches)) {
								$headpics[$i]->imageurl = $matches[1];
							}
							//$this->item->introtext = JHtml::_('string.truncate', strip_tags(JHtml::_('content.prepare', $this->item->introtext)), $introtext_limit);
							$introtext[$i] = strip_tags($headpics[$i]->introtext);
							$headpics[$i]->introtext = mb_substr($introtext[$i], 0, 140);
							$headpics[$i]->created =  preg_replace('/([0-9]{4}-[0-9]{2}-[0-9]{2}).*/',"$1",$headpics[$i]->created);
							echo "<li><img src=".$this->baseurl."/".$headpics[$i]->imageurl." width=650></li>";
						}
						echo "</ul></div>";
						echo "<div id = 'stagebox'>";
						echo "<div id = 'stageindex'><ul>";
						for($i=0;$i<3&&isset($headpics[$i]);$i++){
							$n = $i + 1;
							echo "<li>".$n."</li>";
						}
						echo "</ul></div>";
						echo "<div id = 'stagemsg'><ul>";
						for($i=0;$i<3&&isset($headpics[$i]);$i++){
							echo '<li><div id="hpdesc">'.$headpics[$i]->introtext."</div>";
							echo '<div id="hpdate">'.$headpics[$i]->created."</div></li>";
						}
						echo "</div></ul>";
						echo "</div>";
						echo "</div>";
						$query = 'select con.id, con.alias, con.created, con.title, con.catid
							from
							#__content as con
							where
							con.catid=9
							order by con.created desc
							limit 0,9';
						$db->setQuery($query);
						$events = $db->loadObjectList();
						echo "<div id = 'content'>";
						echo "<div id = 'focus'><div class = 'board'><h2>注意啦</h2></div><div class = 'listbox'><ul>";
						for($i=0;$i<8&&isSet($events[$i]);$i++){
							$events[$i]->created=preg_replace('/([0-9]{4}-[0-9]{1,2}-[0-9]{1,2})(.*)/',"$1",$events[$i]->created);
							echo "<li><span class = 'eventdate'> [ ".$events[$i]->created." ] </span><a href=".JRoute::_(ContentHelperRoute::getArticleRoute($events[$i]->id.":".$events[$i]->alias, $events[$i]->catid))."><span>".$events[$i]->title."</span></a></li>";
						}
						echo "</ul></div></div>";
						/*$query = 'select qca.refdate,qca.short_desc,qca.long_desc
							from
							#__qcalendar as qca
							where
							qca.active=1
							order by qca.refdate desc
							limit 0,9';
						$db->setQuery($query);
						$events = $db->loadObjectList();
						echo "<div id = 'content'>";
						echo "<div id = 'focus'><div class = 'board'><h2>注意啦</h2></div><div class = 'listbox'><ul>";
						for($i=0;$i<8&&isSet($events[$i]);$i++){
							echo "<li><span class = 'eventdate'> [ ".$events[$i]->refdate." ] </span><span>".$events[$i]->long_desc."</span></li>";
						}
						echo "</ul></div></div>";*/
					
					endif;
					
					?>
						
						
						
						
						
						
						
		<jdoc:include type="modules" name="position-13"  />
				<?php if ($menu->getActive()==$menu->getDefault()):?>
				<div id="main">
					<div class = "board">
						<h2><span>大</span>事小情摘要</h2>
					</div>
				<?php endif;?>
					<?php if ($this->countModules('position-12')): ?>
						<div id="top"><jdoc:include type="modules" name="position-12"   /></div>
					<?php endif; ?>

					<?php if ($this->getBuffer('message')) : ?>
						<div class="error">
							<h2>
								<?php echo JText::_('TPL_JM-SCHOOL_SYSTEM_MESSAGE'); ?>
							</h2>
							<jdoc:include type="message" />
						</div>
					<?php endif; ?>			
		<jdoc:include type="component" />	
				<?php if ($menu->getActive()==$menu->getDefault()) echo '<p class = "more"><a  href="index.php/events"><img src="./images/formore.gif"></a></p></div>';?>
				<?php
				if ($menu->getActive()==$menu->getDefault()):
				$query = 'select web.title,web.url
							from
							#__weblinks as web
							where
							web.state=1
							order by web.id desc
							limit 0,7';
						$db->setQuery($query);
						$links = $db->loadObjectList();
				echo "<div id = 'link'><div class = 'board'><h2><span>他</span>山之石</h2></div><div class = 'listbox'><ul>";
						for($i=0;$i<6&&isSet($links[$i]);$i++){
							echo '<li><a target = "_blank" href="'.$links[$i]->url.'">'.$links[$i]->title."</a></li>";
						}
						echo "</ul></div></div>";
				endif;
				?>
				</div>
				
			</div><!-- end wrapper -->
		</div>
		<div class = "clear"></div>


		<?php if ($showbottom) : ?>
			<div id="footer-inner">

				<div id="bottom">
					<?php if ($this->countModules('position-9')): ?>
					<div class="box box1"> <jdoc:include type="modules" name="position-9" style="beezDivision" headerlevel="3" /></div>
					<?php endif; ?>
					   <?php if ($this->countModules('position-10')): ?>
					<div class="box box2"> <jdoc:include type="modules" name="position-10" style="beezDivision" headerlevel="3" /></div>
					<?php endif; ?>
					<?php if ($this->countModules('position-11')): ?>
					<div class="box box3"> <jdoc:include type="modules" name="position-11" style="beezDivision" headerlevel="3" /></div>
					<?php endif ; ?>
				</div>
			</div>
		<?php endif ; ?>


			<?php if (!$templateparams->get('html5', 0)): ?>
				<div id="footer">
			<?php else: ?>
				<footer id="footer">
			<?php endif; ?>

					<p> 
						©2009-2011 &#174; <?php echo JText::_('TPL_JM-SCHOOL_POWERED_BY');?> <a href="<?php echo $this->baseurl; ?>"> 09信息工程4班 </a>All Rights Reserved ！
					</p>
					<p>
						<font align=right>Thank You ! </font>
					</p>

			<?php if (!$templateparams->get('html5', 0)): ?>
				</div><!-- end footer -->
			<?php else: ?>
				</footer>
			<?php endif; ?>


			<jdoc:include type="modules" name="debug" />
	</body>
</html>
